package edu.tces482.plms.zigbee;

public abstract class ZBPacket {
	
	protected static final byte startDelimiter = 0x7E;
	
	protected static final int baseSize = 4;

	
	protected abstract int getFrameSize();
	
	protected abstract byte [] getFrameBytes();
	
	protected byte calculateChecksum(final byte [] bytes, int offset, int length) {
		int sum = 0;
		int i;
		for (i = offset; i < offset + length; i++) {
			int nextByte = (0x000000FF & bytes[i]);
			sum += nextByte;
		}
		return (byte) (0x000000FF - (sum & 0x000000FF));
	}
	
	
	public abstract int getType();

	public int getSize() {
		return (baseSize + getFrameSize());
	}
	
	public void getBytes(final byte [] bytes) {
		
	}
}
